﻿#include<stdio.h>
#include<stdlib.h>
#include"queue.h"
void Shownums(Queue * pq);
int main(){
	Queue he;
	Item ren;
	char ch;
	InitializeQueue(&he);
	puts("Type a to add a value");
	puts("Type d to delete a value");
	puts("Type q to quit");
	while ((ch=getchar())!='q')
	{
		if (ch != 'a'&&ch != 'd')
			continue;
		if (ch=='a')
		{
			puts("Integer to add");
			scanf("%d", &ren.num);
			if (!QueueIsFull(&he))
			{
				printf("Puts %d into queue\n",ren.num);
				EnQueue(ren, &he);
			}
			else
				puts("The queue is full.");
		}
		else
		{
			if (QueueIsEmpty(&he))
				puts("Nothing to delete.");
			else
			{
				DeQueue(&ren, &he);
				printf("Removing %d from queue.\n", ren.num);
			}
		}
		printf("Now %d items in queue\n", QueueItemCount(&he));
		puts("Type a to add a value");
		puts("Type d to add a value");
		puts("Type q to quit");
	}
	//Shownums(&he);
	EmptyQueue(&he);
	puts("BYE");
	system("pause");
	return 0;
}

void Shownums(Queue * pq)
{
	Queue *temp = pq;
	while (temp->front!=NULL)
	{
		printf("%d\n", temp->front->item);
		temp->front = temp->front->next;
	}
}